package com.mebs.edi.model.edi.e214;

import javax.persistence.Column;
import javax.persistence.Embeddable;

import com.mebs.edi.model.dom.DomAttribute;
import com.mebs.edi.model.dom.DomEntity;

/**
 * 
 * L11 section of a 214 EDI file 
 * 
 * @author nit
 *
 */
@Embeddable
@DomEntity(name = "L11")
public class Edi214L11 {
	
	public enum L11Qualifier {
		MESSAGE_IDENTIFIER("FI"), 
		FLIGHT_NUMBER("WU"), 
		ASN_OR_DN_NUMBER("MA"), 
		FILE_CREATION_DATE("TA"),
		STOP_NUMBER("QN"),
		STOP_NUMBER_FINAL("FS");
		
		private String code;
		
		L11Qualifier(String code) {
			this.code = code;
		}
		
		public String getCode() {
			return code;
		}
	}
	
	@Column(nullable = true, length = 30)
	@DomAttribute
	private String l1101; 		// Reference Identification (Stop Number)
	
	@Column(nullable = true, length = 3)
	@DomAttribute
	private String l1102; 		// Reference Identification Qualifier (Data, see .xls)
	
	public Edi214L11() {
		super();
	}

	public String getL1101() {
		return l1101;
	}

	public void setL1101(String l1101) {
		this.l1101 = l1101;
	}

	public String getL1102() {
		return l1102;
	}

	public void setL1102(String l1102) {
		this.l1102 = l1102;
	}

	@Override
	public String toString() {
		return "Edi214L11 [l1101=" + l1101 + ", l1102=" + l1102 + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((l1101 == null) ? 0 : l1101.hashCode());
		result = prime * result + ((l1102 == null) ? 0 : l1102.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Edi214L11 other = (Edi214L11) obj;
		if (l1101 == null) {
			if (other.l1101 != null)
				return false;
		} else if (!l1101.equals(other.l1101))
			return false;
		if (l1102 == null) {
			if (other.l1102 != null)
				return false;
		} else if (!l1102.equals(other.l1102))
			return false;
		return true;
	}

}
